var t = require("../../../../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Component({
    properties: {
        keywork: {
            type: null
        },
        memberId: {
            type: null
        }
    },
    data: {
        typeIndex: "",
        detailUrl: "orderdetail",
        orderType: "shop",
        firstRquery: !1,
        json: {
            page: 1,
            keyword: "",
            order_type: "order",
            status: "1"
        },
        loading: !1,
        finished: !1,
        order_tabs: [],
        orderList: [],
        orderStatusTabs: [],
        strUrl: "plugin.wechat-chat-sidebar.frontend.controller.customer.customer.get-order-list",
        getConfig: {
            client: "work",
            type: 17
        }
    },
    lifetimes: {
        attached: function() {
            this.getData();
        }
    },
    methods: {
        getData: function() {
            var s = this;
            if (!this.data.finished || !this.data.loading) {
                var e = {};
                "refund_order" === this.data.json.order_type ? "customer" == this.data.keywork && (e = {
                    page: this.data.json.page,
                    keyword: this.data.json.keyword
                }, this.data.strUrl = "plugin.customer-center.frontend.controllers.customer.refund-apply", 
                e.member_id = this.data.memberId) : "customer" == this.data.keywork && (e = t({}, this.data.json), 
                this.data.strUrl = "plugin.customer-center.frontend.controllers.customer.get-order-list", 
                e.member_id = this.data.memberId), this.data.loading = !0;
                var r = a.getNetAddresss(this.data.strUrl);
                a._postNetWork({
                    url: r,
                    data: e,
                    success: function(t) {
                        var a = t.data;
                        1 == a.result ? (console.log(a, "ddddddddd"), (s.data.json.page >= a.data.last_page || a.data.data.length < a.data.per_page) && s.setData({
                            finished: !0
                        }), s.data.order_tabs.length <= 0 && (s.data.order_tabs = s.setOrderTabs(a.data), 
                        s.data.orderStatusTabs = s.data.order_tabs[0].list, s.setData({
                            order_tabs: s.data.order_tabs,
                            orderStatusTabs: s.data.orderStatusTabs
                        })), a.data && s.setData({
                            orderList: s.data.json.page > 1 ? s.data.orderList.concat(a.data.data) : a.data.data,
                            "json.page": ++s.data.json.page
                        })) : wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 1500
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        },
        setOrderTabs: function(t) {
            if (t.order_name || t.order) {
                var a = [ {
                    status: 1,
                    status_name: "全部"
                }, {
                    status: 2,
                    status_name: "待付款"
                }, {
                    status: 3,
                    status_name: "待发货"
                }, {
                    status: 4,
                    status_name: "待收货"
                }, {
                    status: 5,
                    status_name: "已完成"
                } ], s = [];
                for (var e in t.order.json) {
                    var r = !0, d = t.order_name[e];
                    e && ("order" === e ? t.order[e] = a : "hotel_order" === e ? t.order[e] = [ {
                        status: 1,
                        status_name: "全部"
                    }, {
                        status: 2,
                        status_name: "待付款"
                    }, {
                        status: 3,
                        status_name: "待确认"
                    }, {
                        status: 4,
                        status_name: "待入住"
                    }, {
                        status: 5,
                        status_name: "已完成"
                    }, {
                        status: 6,
                        status_name: "待退房"
                    } ] : "lease_order" === e ? t.order[e] = [ {
                        status: 1,
                        status_name: "全部"
                    }, {
                        status: 2,
                        status_name: "待支付"
                    }, {
                        status: 3,
                        status_name: "待发货"
                    }, {
                        status: 4,
                        status_name: "待收货"
                    }, {
                        status: 5,
                        status_name: "待归还"
                    }, {
                        status: 6,
                        status_name: "已完成"
                    } ] : "fight_groups_order" === e ? t.order[e] = [ {
                        status: 1,
                        status_name: "全部"
                    }, {
                        status: 2,
                        status_name: "拼团中"
                    }, {
                        status: 3,
                        status_name: "待付款"
                    }, {
                        status: 4,
                        status_name: "待收货"
                    }, {
                        status: 5,
                        status_name: "已完成"
                    } ] : "snatch_regiment_order" === e ? t.order[e] = [ {
                        status: 1,
                        status_name: "抢团中"
                    }, {
                        status: 2,
                        status_name: "待付款"
                    }, {
                        status: 2,
                        status_name: "待发货"
                    }, {
                        status: 3,
                        status_name: "待收货"
                    }, {
                        status: 5,
                        status_name: "已完成"
                    } ] : r = !1, r && s.push({
                        name: e,
                        title: d,
                        list: t.order[e]
                    }));
                }
                return s.push({
                    name: "refund_order",
                    title: "售后订单",
                    list: []
                }), s;
            }
        },
        loadMore: function() {
            this.getData();
        },
        changeOrderType: function(t) {
            console.log(t), console.log(this.data.order_tabs[t.detail], "ddddddd"), this.setData({
                typeIndex: t.detail,
                "json.status": 1,
                "json.order_type": this.data.order_tabs[t.detail].name,
                orderStatusTabs: this.data.order_tabs[t.detail].list
            }), "order" === this.data.json.order_type ? (this.data.detailUrl = "orderdetail", 
            this.data.orderType = "shop") : "hotel_order" === this.data.json.order_type ? (this.data.detailUrl = "HotelOrderDetail", 
            this.data.orderType = "hotel") : "lease_order" === this.data.json.order_type ? (this.data.detailUrl = "LeaseToyOrderDetail", 
            this.data.orderType = "lease_toy") : "fight_groups_order" === this.data.json.order_type ? (this.data.detailUrl = "groupDetail", 
            this.data.orderType = "groups") : "snatch_regiment_order" === this.data.json.order_type && (this.data.detailUrl = "orderdetail", 
            this.data.orderType = "grabGroup"), this.setData({
                orderType: this.data.orderType,
                detailUrl: this.data.detailUrl
            }), this.getParamInit(), this.getData();
        },
        changeOrderStatus: function(t) {
            console.log(t), this.setData({
                "json.status": t.detail.name
            }), this.getParamInit(), this.getData();
        },
        search: function(t) {
            this.setData({
                "json.keyword": t.detail,
                loading: !1,
                finished: !1,
                "json.page": 1
            }), this.getData();
        },
        getParamInit: function() {
            this.setData({
                orderList: [],
                "json.page": 1,
                "json.keyword": "",
                loading: !1,
                finished: !1
            });
        }
    }
});